#define _CRT_SECURE_NO_WARNINGS 1









//https://www.luogu.com.cn/problem/P1910




#include<iostream>
using namespace std;
const int N = 110, M = 1010;
int n, m, x;
int a[N], b[N], c[N];
int dp[M][M];
int main()
{
	cin >> n >> m >> x;
	for (int i = 1;i <= n;i++)
		cin >> a[i] >> b[i] >> c[i];

	for (int i = 1;i <= n;i++)
	{
		for (int j = m;j >= b[i];j--)
		{
			for (int k = x;k >= c[i];k--)
			{
				dp[j][k] = max(dp[j][k], a[i] + dp[j - b[i]][k - c[i]]);
			}
		}
	}
	cout << dp[m][x];
	return 0;
}



